﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Domain.UserManageDomain;
using Zocono.WCS.Infrastructure.ApllicationDto;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoUser;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoWcsManage;

namespace Zocono.WCS.Application.AppTraces
{
    public class TracesApp
    {
        private readonly ITracesService _tracesServic;
        private readonly IUserService _Userservice;
        private readonly ISnowflake _Snowflake;


        public TracesApp(ITracesService traces, IUserService userService, ISnowflake snowflake)
        {
            _tracesServic = traces;
            _Userservice = userService;
            _Snowflake = snowflake;
        }
        public async Task<List<FunctionInfoDto>> GetFunctionInfoAsync()
        {
            return await _Userservice.GetFunctionInfoAsync();
        }
        /// <summary>
        /// 保存操作日志数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<bool> AddTracesAsync(TracesInfo info)
        {
            try
            {
                info.ID = _Snowflake.GetId();
                return await _tracesServic.AddTraces(info);
            }
            catch (Exception e)
            {
                return false;
            }
        }


        /// <summary>
        /// 获取操作日志数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<PageDto<TracesInfoDto>> GetTracesAsync(TracesInfoDto info)
        {
            try
            {
                info.ID = _Snowflake.GetId();
                return await _tracesServic.GetTraces(info);
            }
            catch (Exception e)
            {
                return null;
            }
        }
    }
}
